//
//  UIImage+Common.m
//  代码约束播放界面
//
//  Created by dllo on 16/8/18.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "UIImage+Common.h"

@implementation UIImage (Common)

#pragma mark - 绘制图片，变为绿色
- (UIImage *)imageWithColor:(UIColor *)color
{
    UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context, 1.0, 1.0);
    CGContextSetBlendMode(context, kCGBlendModeNormal);
    CGRect rect = CGRectMake(0, 0, self.size.width - 1, self.size.height - 1);
    CGContextClipToMask(context, rect, self.CGImage);
    [color setFill];
    CGContextFillRect(context, rect);
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

@end
